<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<jsp:include page="include.jsp"></jsp:include>
<script type="text/javascript">
function toVaild(){
	if(!$('#userCode').val()){
		$('#msg').html("请录入用户名");
		return false;
	}
	if(!$('#userPass').val()){
		$('#msg').html("请录入密码");
		return false;
	}
	$('#msg').html("");
	return true;
}
jQuery(function($){
	$("#login").click( function () {
		if(!toVaild()){
			return;
		}
		$.ajax({
			  type: 'POST',
			  url: 'login',
			  async: false,//是否异步
			  contentType: "application/json; charset=utf-8",
		      data: JSON.stringify($('#LoginFM').serializeJSON())
			  ,success: function(d){
				  if(d.error != null && d.error == 1){
					  $('#msg').html(d.msg);
				  }else{
					  window.location.href = "welcome?type=0"; 
				  }
			  }
			  ,error:function(d){
				  //TODO something
				  alert(d.msg);
			  }
		});
	});
	$("#attach").click( function () { 
		 window.location.href = "attachUrl";
	});
});
</script>
</head>
<body style="overflow: hidden;">
	<div data-role="page" id="pageone">
		<div data-role="header"  data-theme="a">
			<h1>欢迎登录(微服务版)</h1>
		</div>
		<div data-role="content">
			<p style="color: red;width: 100%;text-align: center;">&nbsp;<span id="msg">${msg}</span></p>
			<form id="LoginFM" method="GET">
				<div data-role="fieldcontain" style="margin: 10px">
					<label for="userCode">用户名：</label> 
					<input type="text" name="userCode" id="userCode" value="001"> 
					<label for="userPass" data-icon="lock">密码：</label> 
					<input type="password" name="userPass" id="userPass" value="001"> 
					<label for="savePass">记住密码</label>
					<input type="checkbox" name="savePass" id="savePass">
				</div>
				<a id="login" data-role="button" data-icon="check" data-theme="b">登&nbsp;&nbsp;录</a>
				<a href="attachUrl" id="attach" data-role="button" data-icon="info">注&nbsp;&nbsp;册</a>
			</form>
		</div>
		<div data-role="footer" class="ui-btn" data-position="Fullscreen" data-theme="a"><!-- fixed -->
		  <div data-role="controlgroup" data-type="horizontal">
		    <a href="common/connection.jsp" target="_blank" data-role="button" data-icon="email">联系我们</a>
		    <a href="common/download.jsp" target="_blank" data-role="button" data-icon="arrow-d">下载中心</a>
		    <a href="common/help.jsp" target="_blank" data-role="button" data-icon="star">帮助文档</a>
		  </div>
	  	 <p>&copy; NET.GODBIRDS 2017 </p>
		</div>
	</div>
</body>
</html>
